package com.gree.common.service.impl;


import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.gree.common.entity.SysOperLog;
import com.gree.common.service.ISysOperLogService;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 操作日志 服务层处理
 *
 *
 */
@Service
public class SysOperLogServiceImpl implements ISysOperLogService
{
    @Autowired
    private Dao dao;

    /**
     * 新增操作日志
     *
     * @param operLog 操作日志对象
     */
    @Override
    public void insertOperlog(SysOperLog operLog)
    {
        List<Record> cc = dao.query("sys_oper_log",null);
        dao.insert(operLog);
    }

    /**
     * 查询系统操作日志集合
     *
     * @param operLog 操作日志对象
     * @return 操作日志集合
     */
    @Override
    public List<SysOperLog> selectOperLogList(SysOperLog operLog)
    {
        return new ArrayList<SysOperLog>();
    }

    /**
     * 批量删除系统操作日志
     *
     * @param ids 需要删除的数据
     * @return
     */
    @Override
    public int deleteOperLogByIds(String ids)
    {
        return 1;
    }

    /**
     * 查询操作日志详细
     *
     * @param operId 操作ID
     * @return 操作日志对象
     */
    @Override
    public SysOperLog selectOperLogById(Long operId)
    {
        return new SysOperLog();
    }

    /**
     * 清空操作日志
     */
    @Override
    public void cleanOperLog()
    {
    }

    @Override
    public void insertMenulog(String usid, String comp, String teno, Date time) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dnum = df.format(time.getTime());
        Sql sql = Sqls.create("insert into sys_menu_log(usid,comp,teno,time) values (@usid,@comp,@teno,to_date(@time,'yyyy-mm-dd hh24:mi:ss'))");
        sql.setParam("usid",usid)
                .setParam("comp",comp)
                .setParam("teno",teno)
                .setParam("time",dnum);
        dao.execute(sql);
    }
}
